<template>
  <el-select clearable v-model="reqParamsClone.channel_id" placeholder="请选择">
    <el-option v-for="item in channels" :key="item.id" :label="item.name" :value="item.id">
    </el-option>
  </el-select>
</template>

<script>
import { getAllChannelsAPI } from '@/api/index.js'
export default {
  name: 'myChannels',
  props: {
    reqParams: {
      type: Object,
      default: () => ({})
    }
  },
  data () {
    return {
      channelId: null,
      channels: null,
      reqParamsClone: this.reqParams
    }
  },
  created () {
    // 调用获取全部频道方法
    this.loadAllChannels()
  },
  methods: {
    // 获取全部频道方法
    async loadAllChannels () {
      try {
        const { data: res } = await getAllChannelsAPI(this.reqParams)
        console.log(res)
        this.channels = res.data.channels
      } catch (error) {
        console.log(error)
      }
    }
  }
}
</script>

<style>

</style>
